{extend name='bus@public/index'}
{block name="css"}{/block}
{block name="main"}
<div class="ibox-title">
    <h5>角色管理</h5>
    <div class="pull-right mt-2" data-button>
        loading...
    </div>
</div>
<div class="container-fluid" ng-controller="RoleIndexController">
    <!-- 表单搜索 -->
    <div class="search-form form-inline mb-1 mt-3 mb-3">
        <div class="col-md-2">
            <div class="input-group input-group-sm">
                <div class="input-group-prepend">
                    <span class="input-group-text">更多搜索</span>
                </div>
                <input class="form-control" ng-model="model.key" name="key" id="key" placeholder="请输入关键词"  autocomplete="off">
                <button type="button" class="btn btn-info btn-sm ml-2" id="search"><i class="fa fa-search"></i> 搜索</button>

            </div>

        </div>




    </div>
    <!-- 数据表格 -->
    <table id="data_list"  title="角色管理"></table>

</div>

{/block}
{block name="script"}
<script>
    let PageConfig = {
        InfoUrl: '/admin/role/info',
        DeleteUrl: '/admin/role/delete',
        AuditUrl: '',
        ImportUrl: '',
        TemplateUrl: '',
        Area: ['400px', '250px'],
        TableId: 'data_list',
        GetListUrl: '/admin/role/data_list',
        TableColumns: [
            {field: '', checkbox: true, align: 'center', valign: 'middle', width: IdWidth},
            {title: '序号', field: 'id', align: 'center', valign: 'middle', width: IdWidth, formatter: formatTxt.NoTxt},
            {title: '名称', field: 'name', align: 'center', valign: 'middle', width: RoleNameWidth, sortable: true,},
            {title: '状态', field: 'status', align: 'center', valign: 'middle', width: StatusWidth, sortable: true,},
            {title: '备注', field: 'remark',  formatter: frame.tips(20) , width:RemarkWidth, sortable:true, },
            {title: '创建人 ', field: 'create_user_name', align: 'center', valign: 'middle', width:UserNameWidth, sortable:true, },
            {title: '创建日期', field: 'create_time', align: 'center', valign: 'middle', width:DateTimeWidth, sortable:true, },
        ],
        PowerUrl:'/admin/role/power',
    }
</script>
<script>
    app.controller("RoleIndexController", function ($scope, $http, selectFactory, dataFactory) {
        //绑定下拉框
        $scope.type = selectFactory.BasicsType;
        $scope.status = [];
        dataFactory.SelectStatus().then(function (data) {
            $scope.status = data;
        });
        $scope.model = {
            status: '',
            key: '',
        };

        $(function () {
            //初始化表格
            let table = new TableInit($scope);
            table.Init();
        });
    });

    function funcpower(){
        let rows = $('#'+PageConfig.TableId).bootstrapTable("getAllSelections");
        if (rows.length == 0) {
            oob.showIframe({code: -1, msg: "您没有选中任何项,请您选中后再操作。"});
            return false;
        }
        if (rows.length > 1) {
            oob.showIframe({code: -1, msg: "很抱歉,一次只能选择一条记录。"});
            return false;
        }
        parent.layer.open({
            title: '权限设置', type: 2, area: ['800px', '95%'], fix: true, maxmin: false
            , content: PageConfig.PowerUrl + '?id=' + rows[0]['id'],
        });
    }
</script>
{/block}

